﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using RoadTeam.BLL;
using System.Data;
using System.Web.Script.Serialization;
using RoadTeam.Standard;
using RoadTeam.Pub;

public partial class 对接测试页面_CsListItem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        CsListItemBLL bll = new CsListItemBLL();
        DataTable dt = bll.GetCsListItemData();
        CsListItemTemp temp;
        List<CsListItemTemp> li = new List<CsListItemTemp>();
        foreach (DataRow dr in dt.Rows)
        {
            temp = new CsListItemTemp();
            temp.ListItemIdentifier = dr["ListItemIdentifier"].ToString();
            temp.ListItemName = dr["ListItemName"].ToString();
            temp.ListItemRemark = dr["ListItemRemark"].ToString();
            li.Add(temp);
        }

        CsListItem listitem = new CsListItem();
        listitem.Item = li.ToArray();

        JavaScriptSerializer jscvt = new JavaScriptSerializer();
        Response.Write(jscvt.Serialize(listitem));
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
  
// ListItemIdentifier
//ListItemName
//ListItemContent
//ListItemRemark

        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("ListItemIdentifier", typeof(string)));
        dt.Columns.Add(new DataColumn("ListItemName", typeof(string)));
        dt.Columns.Add(new DataColumn("ListItemContent", typeof(string)));
        dt.Columns.Add(new DataColumn("ListItemRemark", typeof(string)));

        DataRow dr;
        for (int i = 0; i < 5; i++)
        {
            dr=dt.NewRow();
            dr["ListItemIdentifier"] = RoadTeam.Pub.CreateIdentifier.GetIdentifier();
            dr["ListItemName"] = "名称测试数据1008600" + i.ToString();
            dr["ListItemContent"] = "内容测试数据1008600" + i.ToString();
            dr["ListItemRemark"] = "备注测试数据1008600" + i.ToString();
            dt.Rows.Add(dr);
        }
        RoadTeam.Model.CsListItem.InsertDatatable(dt, RoadTeam.Enums.GlobalConfig.ConnectionString);

    }
}

//public class CsListItemTemp
//{
//    [XmlElement(ElementName = "ListItemIdentifier", Type = typeof(string))]
//    public String ListItemIdentifier;
//    [XmlElement(ElementName = "ListItemName", Type = typeof(string))]
//    public String ListItemName;
//    [XmlElement(ElementName = "ListItemContent", Type = typeof(string))]
//    public String ListItemContent;
//    [XmlElement(ElementName = "ListItemRemark", Type = typeof(string))]
//    public String ListItemRemark;
//    [XmlElement(ElementName = "ListItemState", Type = typeof(string))]
//    public String ListItemState;
//    //数据状态:新增:Insert    修改:Update   删除:Delete
//}

//public class CsListItem
//{
//    [XmlElement(ElementName = "Item")]
//    public CsListItemTemp[] Item;
//}


